package com.jcf.springboot.service;

import cn.hutool.core.date.DateUtil;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;


/**
 * @author ${chaofan.ji}
 * @since 2025/4/20
 */
@Service
public class RabbitmqService {
  @Value("${exchange.name}")
  private String exchangeName;

  @Autowired
  private RabbitTemplate rabbitTemplate;

  public void sendMessage(){
    String text = DateUtil.now() + "welcome to rabbit fanout exchange";
    Message message = new Message(text.getBytes(),new MessageProperties());
    rabbitTemplate.send(exchangeName,"",message);
  }
}
